<!DOCTYPE html>
<html>
<head>
    <title>设备信息</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.devName" @on-enter="query" placeholder="设备名称"></i-input>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.devProductName" @on-enter="query" placeholder="生产线名称/生产线代码"></i-input>
                </i-col>
                <i-col span="4">
                    <i-input v-model="q.devProceName" @on-enter="query" placeholder="工序名称/工序号"></i-input>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>

<script>
    var devQueryUrl = '../deviceinfo/list';
    var queryParam = '';
    // 是否查询指定设备组织下的设备列表
    var deptCode = getQueryString('deptCode');
    if (deptCode) {
        queryParam = 'deptCode=' + deptCode;
    }

    // 查询指定工装下可以添加的设备列表
    var toolsCheckPlanId = getQueryString('toolsCheckPlanId');
    if (toolsCheckPlanId) {
        queryParam += (queryParam ? '&' : '') + 'toolsCheckPlanId=' + toolsCheckPlanId;
    }
    if (queryParam) {
        devQueryUrl += '?' + queryParam;
    }
    $(function () {
        $("#jqGrid").Grid({
            url: devQueryUrl,
            rownumWidth: 40,
            colModel: [
                {label: '设备编码', name: 'devCode', index: 'DEV_CODE', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 80},
                {label: '小类', name: 'devTypeSName', index: 'devTypeSName', width: 80},
                {label: '生产线代码', name: 'devProductCode', index: 'DEV_PRODUCT_CODE', width: 60},
                {label: '生产线名称', name: 'devProductName', index: 'DEV_PRODUC_NAMET', width: 100},
                {label: '工序号', name: 'devProceNo', index: 'DEV_PROCE_NO', width: 60},
                {label: '工序名称', name: 'devProceName', index: 'DEV_PROCE_NAME', width: 80},
                {label: '供应厂家', name: 'devSupplyName', width: 80},
                {label: '所属车间', name: 'devFarm', hidden: true},
                {label: '所属车间', name: 'devFarmName', hidden: true},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true}
            ]
        });
    });

    let vm = new Vue({
        el: '#rrapp',
        data: {
            q: {
                devName: '',
                devProductName: '',
                devProceName: ''
            }
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                vm.showList = true;
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function () {
                vm.q = {
                    devName: '',
                    devProductName: '',
                    devProceName: ''
                };
                vm.reload();
            }
        }
    });
    var getDeviceInfo = function () {
        let result = getSelectedRows("#jqGrid");
        if(result.length == 0){
            iview.Message.error("请至少选择一台设备");
            return;
        }
        return result;
    }
</script>
</body>
</html>
